package hc.bre

import hc.bre.rest.cmn.SpringContext
import hc.bre.rest.manage.MainService
import hc.bre.runner.ClassLoaderRunner
import org.junit.jupiter.api.Test
import org.springframework.boot.test.context.SpringBootTest

@SpringBootTest
@groovy.transform.CompileStatic
class BusinessRuleEngineApplicationTests {
	@Test
	void config() {
		List<ComponentConfig> lst = ComponentRegistry.componentList;

		lst.each {
			def ruleDef = it.ruleClass.getConstructor().newInstance()
			assert ruleDef != null;
		}
	}

	@Test
	void configOfCode() {
		assert ComponentRegistry.componentList.size()>0;
		ComponentConfig item = ComponentRegistry.componentList[0];

		assert item.ruleClass != null;

		assert ComponentRegistry.get(item.rtype) == item;
		assert ComponentRegistry.get(item.ruleClass) == item;
	}
	
	@Test
	void contextAware()
	{
		assert SpringContext.applicationContext.getBean(MainService.class) instanceof MainService;
		assert SpringContext.getProp("rule.dir") != null
	}
	

}
